<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<!-- <header class="mui-bar mui-bar-nav">
			<a  class="mui-icon mui-icon-right-nav mui-pull-right" 
				style="color:#007AFF;font-size: 14px;line-height: 25px;"
				id="readcoachs">教练列表</a>
			<h1 class="mui-title">健身方案</h1>
		</header></br></br></br> -->
	</head>
	<style type="text/css">
		.sport{
			line-height: 4.2rem;
			font-size: 1rem;
		}
		.dowhat{
			
		}
		.coach{
			line-height: 2rem;
		}
		.plan{
			height: 5rem;
			line-height: 5rem;
			text-align: center;
			color: #fff;
			background: coral;
		}
		.link-area {
			display: block;
			margin-top: 25px;
			text-align: center;
		}
	</style>
	<body>
		
		<ul class="mui-table-view" id="getcoachinfo">
			<li class="mui-table-view-cell mui-media coach">
				<a href="javascript:;">
					<span class="mui-pull-right mui-icon mui-icon-arrowright" 
							style="line-height: 42px;color: lightgray;margin-left: 3px;line-height: 4rem;"></span>
					<img class="mui-media-object mui-pull-right" src="image/default.jpg" id="coach_photo">
					
					<div class="mui-media-body">
						<span id="coach_name"></span>
						<p class="mui-ellipsis" id="coach_slogan"></p>
					</div>
				</a>
			</li>
		</ul>
		<div class="plan">
			健身方案
		</div>
		<div class="dowhat">
			<ul class="mui-table-view">
					<li class="mui-table-view-cell sport">
						健走
						<span class="mui-badge mui-badge-primary" id="walk_time"></span>
					</li>
					<li class="mui-table-view-cell sport">
						跑步
						<span class="mui-badge mui-badge-success" id="run_time"></span>	 
						
					</li>
					<li class="mui-table-view-cell sport">
						骑行
						<span class="mui-badge mui-badge-warning" id="bike_time"></span>	 
						
					</li>
					<li class="mui-table-view-cell sport">
						 无氧
						<span class="mui-badge mui-badge-danger" id="train_time"></span>	
					</li>
				</ul>
		</div>
		<div class="link-area"><a id='readcoachs'>教练列表</a> <span class="spliter"></div>
		<script src="js/mui.js"></script>
		<script src="js/app.js"></script>
		
		<script type="text/javascript">
			mui.init()
			mui.plusReady(function () {
				mui.ajax(app.serverUrl+'/user/readSchemeByUid',{
					data:{
						uid:app.getUserGlobal().id
					},
					dataType:'json',//服务器返回json格式数据
					type:'get',//HTTP请求类型
					timeout:10000,//超时时间设置为10秒；
					success:function(data){
						console.log(JSON.stringify(data));
						app.setSchemeGlobal(data.data);
						//设置教练/方案等信息
						readcoach();
						
						
					},
					error:function(xhr,type,errorThrown){
						
					}
				});
				var getcoachinfo = document.getElementById("getcoachinfo");
				getcoachinfo.addEventListener('tap',function(){
					var cid = app.getSchemeGlobal().cid;
					mui.openWindow({
						url:"coach/my_caoch.html",
						id:"my_caoch.html",
						extras:{
							cid:cid
						}
					});
				});
				var readcoachs = document.getElementById("readcoachs");
				readcoachs.addEventListener('tap',function(){
					mui.openWindow("coach/coachs.html","coachs.html");
				})
				
			});
			function readscheme(schemedata){
				
				
				
				console.log(schemedata[0].walking);
				console.log(JSON.stringify(schemedata));
				var walk_time = document.getElementById("walk_time");
				var run_time = document.getElementById("run_time");
				var bike_time = document.getElementById("bike_time");
				var train_time = document.getElementById("train_time");
				walk_time.innerHTML = schemedata[0].walking+"分钟";
				run_time.innerHTML = schemedata[0].runing+"分钟";
				bike_time.innerHTML = schemedata[0].bike+"分钟";
				train_time.innerHTML = schemedata[0].training+"分钟";
			}
			function readcoach(){
				var coach = app.getSchemeGlobal();
				var coach_photo = document.getElementById("coach_photo");
				var coach_name = document.getElementById("coach_name");
				var coach_slogan = document.getElementById("coach_slogan");
				coach_photo.src = app.serverUrl+coach.picture;
				coach_name.innerHTML = coach.name;
				coach_slogan.innerHTML = coach.slogan;
				readscheme(coach.schemes);
			}

		</script>

	</body>

</html>
